<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>date</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_339">&nbsp;</a>NAME</h4><blockquote>
date - write the date and time
</blockquote><h4><a name = "tag_001_014_340">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

date <b>[</b>-u<b>] [</b>+<i>format</i><b>]</b>

date <b>[</b>-u<b>] </b><i>mmddhhmm</i><b>[[</b><i>cc</i><b>]</b><i>yy</i><b>] 
</b></code>
</pre>
</blockquote><h4><a name = "tag_001_014_341">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>date</i>
utility writes the date and time to standard output
or attempts to set the system date and time.
&nbsp;By default, the current date and time will be written.
If an operand beginning with
"+"
is specified, the output format of
<i>date</i>
will be controlled by the field descriptors and other text in the operand.
</blockquote><h4><a name = "tag_001_014_342">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>date</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following option is supported:
<dl compact>

<dt><b>-u</b>
<dd>Perform operations as if the
<i>TZ</i>
environment variable was set to the string
UTC0,
or its equivalent historical value of
GMT0.
Otherwise,
<i>date</i>
will use the timezone indicated by the
<i>TZ</i>
environment variable or the system default if that variable is not set.

</dl>
</blockquote><h4><a name = "tag_001_014_343">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt>+<i>format</i><dd>
When the format is specified, each field descriptor
will be replaced in the standard output by
its corresponding value.
All other characters will be copied to the output without change.
The output will always be terminated with a
newline
character.

</dl>
<h5><a name = "tag_001_014_343_001">&nbsp;</a>Field Descriptors</h5>
<dl compact>

<dt><b>%a</b><dd>Locale's abbreviated weekday name.

<dt><b>%A</b><dd>Locale's full weekday name.

<dt><b>%b</b><dd>Locale's abbreviated month name.

<dt><b>%B</b><dd>Locale's full month name.

<dt><b>%c</b><dd>Locale's appropriate date and time representation.

<dt><b>%C</b><dd>Century (a year divided by 100 and truncated to an integer)
as a decimal number [00-99].

<dt><b>%d</b><dd>Day of the month as a decimal number [01-31].

<dt><b>%D</b><dd>Date in the format
<i>mm/dd/yy .</i>

<dt><b>%e</b><dd>Day of the month as a decimal number
[1-31] in a two-digit field with leading
space character
fill.

<dt><b>%h</b><dd>A synonym for
<b>%b</b>.

<dt><b>%H</b><dd>Hour (24-hour clock) as a decimal number [00-23].

<dt><b>%I</b><dd>Hour (12-hour clock) as a decimal number [01-12].

<dt><b>%j</b><dd>Day of the year as a decimal number [001-366].

<dt><b>%m</b><dd>Month as a decimal number [01-12].

<dt><b>%M</b><dd>Minute as a decimal number [00-59].

<dt><b>%n</b><dd>A
newline
character.

<dt><b>%p</b><dd>Locale's equivalent of either
AM
or
PM.

<dt><b>%r</b><dd>12-hour clock time [01-12] using the AM/PM
notation; in the POSIX locale, this will be equivalent to
"%I:%M:%S %p".

<dt><b>%S</b><dd>Seconds as a decimal number [00-61].

<dt><b>%t</b><dd>A
tab
character.

<dt><b>%T</b><dd>24-hour clock time [00-23] in the format
<i>HH:MM:SS .</i>

<dt><b>%u</b><dd>Weekday as a decimal number [1 (Monday)-7].

<dt><b>%U</b><dd>Week of the year (Sunday as the first day of the week)
as a decimal number [00-53].
All days in a new year preceding the first Sunday are considered
to be in week 0.

<dt><b>%V</b><dd>Week of the year (Monday as the first day of the week)
as a decimal number [01-53].
If the week containing
January 1 has four or more days in the new year, then it is considered week 1;
otherwise, it is the last week of the previous year, and the
next week is week 1.

<dt><b>%w</b><dd>Weekday as a decimal number [0 (Sunday)-6].

<dt><b>%W</b><dd>Week of the year (Monday as the first day of the week)
as a decimal number [00-53].
All days in a new year preceding the first Monday are considered
to be in week 0.

<dt><b>%x</b><dd>Locale's appropriate date representation.

<dt><b>%X</b><dd>Locale's appropriate time representation.

<dt><b>%y</b><dd>Year within century [00-99].

<dt><b>%Y</b><dd>Year with century as a decimal number.

<dt><b>%Z</b><dd>Timezone name, or no characters if no timezone is determinable.

<dt><b>%%</b><dd>A percent sign character.

</dl>
<p>
See the LC_TIME description in
the <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b>&nbsp;</a> 
for the field descriptor values in the POSIX locale.
<h5><a name = "tag_001_014_343_002">&nbsp;</a>Modified Field Descriptors</h5>
Some field descriptors can be modified by the
E
and
O
modifier
characters to indicate a different format or specification as
specified in the LC_TIME locale description (see
the <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b>&nbsp;</a> ).
If the corresponding keyword (see
<b>era</b>,
<b>era_year</b>,
<b>era_d_fmt</b>
and
<b>alt_digits</b>
in
the <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b>&nbsp;</a> )
is not specified or not supported for
the current locale, the unmodified field descriptor value will be used.
<dl compact>

<dt><b>%Ec</b><dd>Locale's alternative appropriate date and time representation.

<dt><b>%EC</b><dd>The name of the base year (period) in the locale's alternative representation.

<dt><b>%Ex</b><dd>Locale's alternative date representation.

<dt>%EX<dd>Locale's alternative time representation.

<dt><b>%Ey</b><dd>Offset from
<b>%EC</b>
(year only) in the locale's alternative representation.

<dt><b>%EY</b><dd>Full alternative year representation.

<dt><b>%Od</b><dd>Day of month using the locale's alternative numeric symbols.

<dt><b>%Oe</b><dd>Day of month using the locale's alternative numeric symbols.

<dt><b>%OH</b><dd>Hour (24-hour clock) using the locale's alternative numeric symbols.

<dt><b>%OI</b><dd>Hour (12-hour clock) using the locale's alternative numeric symbols.

<dt><b>%Om</b><dd>Month using the locale's alternative numeric symbols.

<dt><b>%OM</b><dd>Minutes using the locale's alternative numeric symbols.

<dt><b>%OS</b><dd>Seconds using the locale's alternative numeric symbols.

<dt><b>%Ou</b><dd>Weekday as a number in the locale's alternative representation (Monday = 1).

<dt><b>%OU</b><dd>Week number of the year (Sunday as the first day of the
week) using the locale's alternative numeric symbols.

<dt><b>%OV</b><dd>Week number of the year (Monday as the first day of the
week, rules corresponding to
<b>%V</b>),
using the locale's alternative numeric symbols.

<dt><b>%Ow</b><dd>Weekday as a number in the locale's alternative representation (Sunday = 0).

<dt><b>%OW</b><dd>Week number of the year (Monday as the first day of the
week) using the locale's alternative numeric symbols.

<dt><b>%Oy</b><dd>Year (offset from
<b>%C</b>)
in alternative representation.

</dl>
<p>
<li>
<i>mmddhhmm</i><b>[[</b><i>cc</i><b>]</b><i>yy</i><b>]</b>
<br>
Attempt to set the system date and time
from the value given in the operand.
This is only possible if the user has appropriate privileges and
the system permits the setting of the system date and time.
The first
<i>mm</i>
is the month (number);
<i>dd</i>
is the day (number);
<i>hh</i>
is the hour (number, 24-hour system);
the second
<i>mm</i>
is the minute (number);
<i>cc</i>
is the century and is the first two digits of the year (this is
optional);
<i>yy</i>
is the last two digits of the year and is optional.
If century is not specified, then values in the range
[69-99] refer to years in the twentieth century
(1969 to 1999 inclusive), and values in the range [00-68] refer to
years in the twenty-first century (2000 to 2068 inclusive).
<p>
</>
</blockquote><h4><a name = "tag_001_014_344">&nbsp;</a>STDIN</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_345">&nbsp;</a>INPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_346">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>date</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>LC_TIME</i><dd>
Determine the format and contents of date and time
strings written by
<i>date</i>.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
<dt><i>TZ</i><dd>Determine the timezone in which the time and date are
written, unless the
<b>-u</b>
option is specified.
If the
<i>TZ</i>
variable is not set and the
<b>-u</b>
is not specified, an unspecified system default timezone is used.

</dl>
</blockquote><h4><a name = "tag_001_014_347">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_348">&nbsp;</a>STDOUT</h4><blockquote>
When no formatting operand is specified, the output
in the POSIX locale is equivalent to specifying:
<pre>
<code>
date "+%a %b %e %H:%M:%S %Z %Y"
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_349">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_350">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_351">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_352">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>The date was written successfully.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_353">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_354">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
Field descriptors are of unspecified format when not in the
POSIX locale.
Some of them can contain
newline characters
in some locales, so it may be difficult to use the format shown in
standard output for parsing the output of
<i>date</i>
in those locales.
<p>
The range of values for
<b>%S</b>
extends from 0 to 61 seconds to accommodate the occasional leap second
or double leap second.
<p>
Although certain of the field descriptors in the POSIX locale
(such as the name of the month)
are shown with initial capital letters, this need not be
the case in other locales.
Programs using these fields may need to adjust the capitalisation
if the output is going to be used at the beginning of a sentence.
<p>
The date string formatting capabilities are intended for use in
Gregorian style calendars, possibly with a different starting
year (or years).
The
<b>%x</b>
and
<b>%c</b>
field descriptors, however, are
intended for local representation;
these may be based on a
different, non-Gregorian calendar.
<p>
The
<b>%C</b>
field descriptor was introduced to allow a fallback for the
<b>%EC</b>
(alternative year format base year);
it can be viewed as
the base of the current subdivision in the Gregorian calendar.
A century is not calculated as an ordinal number;
this Guide was published in century 19, not the twentieth.
Both the
<b>%Ey</b>
and
<b>%y</b>
can then be viewed as the offset from
<b>%EC</b>
and
<b>%C</b>,
respectively.
<p>
The
E
and
O
modifiers modify the traditional field descriptors,
so that they can always be used, even if the implementation (or
the current locale) does not support the modifier.
<p>
The
E
modifier supports alternative date formats, such as the
Japanese Emperor's Era, as long as these are based on the
Gregorian calendar system.
Extending the
E
modifiers to other
date elements may provide an implementation-dependent extension
capable of supporting other calendar systems, especially in
combination with the
O
modifier.
<p>
The
O
modifier supports time and date formats using the locale's alternative
numerical symbols, such as Kanji or Hindi digits or ordinal
number representation.
<p>
Non-European locales, whether they use Latin digits
in computational items or not, often have local forms of
the digits for use in date formats.
This is not totally unknown even in Europe;
a variant of dates uses Roman numerals for the months:
the third day of September 1991 would be
written as 3.IX.1991.
In Japan, Kanji digits are regularly used for dates;
in Arabic-speaking countries, Hindi digits are used.
The
<b>%d</b>,
<b>%e</b>,
<b>%H</b>,
<b>%I</b>,
<b>%m</b>,
<b>%S</b>,
<b>%U</b>,
<b>%w</b>,
<b>%W</b>
and
<b>%y</b>
field descriptors
always return the date and time field in Latin digits (that is, 0 to 9).
The
<b>%O</b>
modifier was introduced to support the use
for display purposes of non-Latin digits.
In the LC_TIME category
in
<i><a href="localedef.html">localedef</a></i>,
the optional
<b>alt_digits</b>
keyword is intended
for this purpose.
As an example, assume the following (partial)
<i><a href="localedef.html">localedef</a></i>
source:
<pre>
<code>
alt_digits    "";"I";"II";"III";"IV";"V";"VI";"VII";"VIII" \
              "IX";"X";"XI";"XII"
d_fmt         "%e.%Om.%Y"
</code>
</pre>
With the above date, the command:
<pre>
<code>
date "+%x"
</code>
</pre>
would yield 3.IX.1991.
With the same
<b>d_fmt</b>,
but without the
<b>alt_digits</b>,
the command would yield 3.9.1991.
</blockquote><h4><a name = "tag_001_014_355">&nbsp;</a>EXAMPLES</h4><blockquote>
<ol>
<p>
<li>
The following are input/output examples of
<i>date</i>
used at arbitrary times in the POSIX locale:
<pre>
<code>
<b>$</b> date
<b>Tue Jun 26 09:58:10 PDT 1990</b>
</code>
</pre>
<pre>
<code>
<b>$</b> date "+DATE: %m/%d/%y%nTIME: %H:%M:%S"
<b>DATE: 11/02/91
TIME: 13:36:16</b>
</code>
</pre>
<pre>
<code>
<b>$</b> date "+TIME: %r"
<b>TIME: 01:36:32 PM</b>
</code>
</pre>
<p>
<li>
Examples for Denmark, where the
default date and time format is
"%a %d %b %Y %T %Z":
<pre>
<code>
<b>$</b> LANG=da_DK.iso_8859-1 date
<b>ons 02 okt 1991 15:03:32 CET
</b></code>
</pre>
<pre>
<code>
<b>$</b> LANG=da_DK.iso_8859-1 date"+DATO:%Aden%e.%B%Y%nKLOKKEN:%H:%M:%S"
<b>DATO: onsdag den  2. oktober 1991
KLOKKEN: 15:03:56
</b></code>
</pre>
<p>
<li>
Examples for Germany, where the
default date and time format is
"%a %d.%h.%Y, %T %Z":
<pre>
<code>
<b>$</b> LANG=De_DE.88591 date
<b>Mi 02.Okt.1991, 15:01:21 MEZ
</b></code>
</pre>
<pre>
<code>
<b>$</b> LANG=De_DE.88591 date "+DATUM: %A, %d. %B %Y%nZEIT:  %H:%M:%S" 
<b>DATUM: Mittwoch, 02. Oktober 1991
ZEIT:  15:02:02
</b></code>
</pre>
<br>
<p>
<li>
Examples for France, where the
default date and time format is
"%a %d %h %Y %Z %T":
<pre>
<code>
<b>$</b> LANG=Fr_FR.88591 date
<b>Mer 02 oct 1991 MET 15:03:32
</b></code>
</pre>
<pre>
<code>
<b>$</b> LANG=Fr_FR.88591 date "+JOUR:  %A %d %B %Y%nHEURE: %H:%M:%S"
<b>JOUR:  Mercredi 02 octobre 1991
HEURE: 15:03:56
</b></code>
</pre>
<p>
</ol>
</blockquote><h4><a name = "tag_001_014_356">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_357">&nbsp;</a>SEE ALSO</h4><blockquote>
The <b>XSH</b> specification description of
<i><a href="../xsh/ctime.html">ctime()</a></i>,
<i><a href="../xsh/printf.html">printf()</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
